import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

import java.util.Scanner;

public class PhoneNum {
    public static void main(String[] args) {
        System.out.println("请输入手机号");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.next();


        int num;
        num=(int)(Math.random()*8999)+1000;

        DefaultProfile profile = DefaultProfile.getProfile("default", "LTAIKcjNO3ZYpOSF", "S1AuqOcAymB90rsC1vOvP6eCw8C0e9");
        IAcsClient client = new DefaultAcsClient(profile);
        CommonRequest request = new CommonRequest();
        //request.setProtocol(ProtocolType.HTTPS);
        request.setMethod(MethodType.POST);
        request.setDomain("dysmsapi.aliyuncs.com");
        request.setVersion("2017-05-25");
        request.setAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", name);
        request.putQueryParameter("TemplateCode", "SMS_163030087");
        request.putQueryParameter("SignName", "云龙科技");
        request.putQueryParameter("TemplateParam", "{code:"+num+"}");
        try {
            CommonResponse response = client.getCommonResponse(request);
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
        System.out.println("请输入手机验证码");
        Scanner sca = new Scanner(System.in);
        Integer pwd = scanner.nextInt();
        if (pwd!=num){
            System.out.println("验证码错误");
        }else {
            System.out.println("欢迎登录");
        }
    }
    }

